package net.zoneland.zrdp.framework.web.domain.mapstruct;

import com.branchitech.account.ldap.Department;
import com.branchitech.account.ldap.UserBean;
import net.zoneland.zrdp.framework.web.domain.bean.SearchPersonUserInfo;
import net.zoneland.zrdp.framework.web.domain.vo.CompanyDepartmentVo;
import net.zoneland.zrdp.framework.web.domain.vo.SelectUserVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface PeopleSelectConverter {

    PeopleSelectConverter INSTANCE = Mappers.getMapper(PeopleSelectConverter.class);


    @Mapping(source = "department.dn", target = "dn")
    @Mapping(source = "department.name", target = "name")
    @Mapping(target = "fullName", expression = "java(net.zoneland.zrdp.framework.utils.OrgUtil.getFullNameByDeptDn(department.getDn()))")
    @Mapping(source = "department.containsSubDepts", target = "leaf")
    @Mapping(source = "parentDn", target = "parentDn")
    CompanyDepartmentVo departmentToCompanyDepartmentVo(final Department department, final String parentDn);

    @Mapping(source = "userBean.userID", target = "userId")
    @Mapping(source = "userBean.userName", target = "userName")
    @Mapping(source = "userBean.mobilePhone", target = "mobilePhone")
    @Mapping(source = "userBean.departmentDN", target = "departmentDn")
    @Mapping(source = "userBean.deptName", target = "deptName")
    @Mapping(source = "parentDeptName", target = "deptFullName")
    SelectUserVo userBeanToSelectUserVo(final UserBean userBean, final String parentDeptName);


    @Mapping(source = "userID", target = "userId")
    @Mapping(source = "userName", target = "userName")
    @Mapping(source = "mobilePhone", target = "mobilePhone")
    @Mapping(source = "departmentDN", target = "departmentDn")
    @Mapping(source = "deptName", target = "deptName")
    @Mapping(target = "deptFullName", expression = "java(net.zoneland.zrdp.framework.utils.OrgUtil.getFullNameByDeptDn(userInfo.getDepartmentDN()))")
    SelectUserVo searchPersonUserInfoToSelectUserVo(final SearchPersonUserInfo userInfo);

}
